Add-Type -As System.IO.Compression.FileSystem

$dropFolder = $args[0]
$buildName = (Split-Path -Leaf $dropFolder)

# Copy zip file to destination server
$zipFile =  $buildName + ".zip"
$zipFilePath = Join-Path -Path $dropFolder -ChildPath $zipFile
Copy-Item -Path $zipFilePath -Destination .

# Extract and remove zip file 
[IO.Compression.ZipFile]::ExtractToDirectory($zipFile, $buildName)
Remove-Item $zipFile

# Run deployment
Set-Location $buildName
Invoke-Expression .\Undeploy.ps1
Invoke-Expression .\Deploy.ps1